<script type="text/javascript">
    //上传图片
    function upload(n) {
        var of = $('#uploadFile' + n);
        //检查是否选择了图片
        if (of.val() == '') {
            alert('请先选择图片');
            return;
        }
        //将file移动至上传表单
        $('#fileContent').empty();
        $('#fileContent').append(of);
        //复制一个file放至原处
        $('#ufc' + n).append(of.clone());
        //修改属性
        of.attr('id', '');

        of.attr('name', 'uploadFile');
        //其他表单
        $('#ufFileName').val($('#fileName' + n).val());
        $('#ufWidth').val($('#zoomWidth' + n).val());
        $('#ufHeight').val($('#zoomHeight' + n).val());
        $('#uploadNum').val(n);
        $('#uploadForm').submit();
    }
    //剪裁图片
    function imgCut(n) {
        if ($('#uploadImgPath' + n).val() == '') {
            alert("请先上传图片>");
            return;
        }
        var url = "../common/image_area_select.htm?uploadNum=" + n + "&imgSrcPath="
                + $("#uploadImgPath" + n).val() + "&zoomWidth=" + $("#zoomWidth" + n).val() + "&zoomHeight=" + $("#zoomHeight" + n).val();
        window.open(url, "imgcut", "height=550, width=1000, top=0, left=0, toolbar=no, menubar=no, scrollbars=auto, resizable=yes,location=no, status=no");
    }
    //清除图片
    function clearImg(n) {
        $('#uploadImgPath' + n).val("");
        $('#preImg' + n).attr("src", "");
    }

    //预览图片
    function previewImg(n) {
        var img = $("#uploadImgPath" + n).val();
        if (img != "") {
            if (img.indexOf("?") == -1) {
                $("#preImg" + n).attr("src", img + "?d=" + new Date() * 1);
            } else {
                $("#preImg" + n).attr("src", img + "&d=" + new Date() * 1);
            }
            if (!$("#preImg" + n).attr("noResize")) {
                $("#preImg" + n).css("width", "78");
                $("#preImg" + n).css("height", "78");
            }
        } else {
            $("#preImg" + n).removeAttr("src");
        }
    }
</script>
<form id="uploadForm" action="../common/o_upload_image.htm" method="post" enctype="multipart/form-data"
      target="hiddenIframe" style="display:none;width:0px;height:0px;">
    <span id="fileContent">　</span>
    <input id="ufWidth" type="hidden" name="zoomWidth"/>
    <input id="ufHeight" type="hidden" name="zoomHeight"/>
    <input id="uploadNum" type="hidden" name="uploadNum"/>
    <input id="ufFileName" type="hidden" name="fileName"/>
</form>
<iframe name="hiddenIframe" frameborder="0" border="0" style="display:none;width:0px;height:0px;"></iframe>